<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="./../home.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content" >

        <div class="col-lg-12">
            <h3 class="page-header" id="comercio">
                Administracion de 
                <h:outputText value="Perfiles" style="color:#00BFFF;" />
                <h:link value="Regresar a Listado" outcome="list.xhtml" styleClass="pull-right" style="font-size: 16px; margin-right: 30px;"  />
            </h3>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-primary">
                    <h:messages id="msg" globalOnly="true" styleClass="list-group" infoClass="list-group-item list-group-item-success"
                                errorClass="list-group-item list-group-item-danger" />
                    <div class="panel-heading" style="font-weight: bold;">Registro de Perfiles</div>
                    <div class="panel-body">
                        <h:form id="frmRegistrarPerfil" styleClass="form-horizontal" >
                            <f:event type="preRenderView" listener="#{rolBean.initInsercion}" />
                            <h:messages globalOnly="true" styleClass="list-group" infoClass="list-group-item list-group-item-success"
                                        errorClass="list-group-item list-group-item-danger" />
                            <div class="form-group has-feedback">
                                <label for="idperfil" style="font-size: 15px;" class="col-sm-2 control-label">Perfil :</label>
                                <div class="col-sm-5">
                                    <p:inputText styleClass="form-control" id="idperfil" value="#{rolBean.rol.nombre}" />
                                </div>
                            </div>

                            <p:dataTable value="#{rolBean.modulos}" var="sale">
                                <f:facet name="header" >
                                    Asignación de Permisos
                                </f:facet>

                                <p:column headerText="Modulos">
                                    <h:outputLabel value="#{sale.nombre}" />
                                </p:column>

                                <p:column headerText="Listar" >
                                    <p:selectBooleanCheckbox id="box" value="#{sale.permiso.listar}" rendered="#{sale.listar eq true}" >
                                        <p:ajax event="change" process="box" update="idch idch2 idch3"/>
                                    </p:selectBooleanCheckbox>
                                </p:column>

                                <p:column headerText="Crear"  >
                                    <p:selectBooleanCheckbox id="idch"  value="#{sale.permiso.crear}" rendered="#{sale.crear eq true}" disabled="#{!sale.permiso.listar}"/>
                                </p:column>

                                <p:column headerText="Actualizar" >
                                    <p:selectBooleanCheckbox  id="idch2" value="#{sale.permiso.actualizar}" rendered="#{sale.actualizar eq true}" disabled="#{!sale.permiso.listar}"/>
                                </p:column>

                                <p:column headerText="Eliminar" >
                                    <p:selectBooleanCheckbox  id="idch3" value="#{sale.permiso.eliminar}" rendered="#{sale.eliminar eq true}" disabled="#{!sale.permiso.listar}"/>
                                </p:column>
                            </p:dataTable>

                            <br/>
                            <p:commandButton value="Guardar" actionListener="#{rolBean.insertarPerfil}" update="@form" styleClass="btn btn-primary"/>
                               <!-- rendered="#{sale.listar eq true}"-->


                        </h:form>
                    </div>
                </div>
            </div>
        </div>
    </ui:define>
</ui:composition>

